package jgl.vajra.operator.part.home.fragment;

import android.content.Intent;
import android.net.Uri;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.util.HashMap;
import java.util.Map;

import jgl.vajra.operator.R;
import jgl.vajra.operator.bean.LoginInfoBean;
import jgl.vajra.operator.databinding.FragmentMinePageBinding;
import jgl.vajra.operator.event.ModifyInformationEvent;
import jgl.vajra.operator.manager.AccountManager;
import jgl.vajra.operator.manager.IntentManager;
import jgl.vajra.operator.manager.VoiceManager;
import jgl.vajra.operator.part.home.contract.MinePageContract;
import jgl.vajra.operator.part.home.viewModel.MinePageViewModel;
import jgl.vajra.operator.widget.mvvm.factory.CreateViewModel;
import jgl.vajra.operator.widget.mvvm.view.BaseMVVMFragment;
import jgl.vajra.operator.widget.utils.ToastUtils;
import jgl.vajra.operator.widget.utils.UIUtils;

@CreateViewModel(MinePageViewModel.class)
public class MinePageFragment extends BaseMVVMFragment<MinePageViewModel, FragmentMinePageBinding> implements MinePageContract.View {

    private LoginInfoBean loginInfoData=new LoginInfoBean();

    @Override
    public int getLayoutId() {
        return R.layout.fragment_mine_page;
    }

    @Override
    public void initView() {
        mBinding.setView(this);

        requestNetData();
    }

    private void requestNetData() {
        Map<String, Object> map = new HashMap<>();
        map.put("Authorization", AccountManager.getInstance().getLoginData(UIUtils.getContext()).authorization);
        mViewModel.getMineData(map);
    }

    @Override
    public void initData() {

    }

    @Override
    public void initEvent() {

    }

    //设置
    @Override
    public void onSetting() {
        IntentManager.toSettingPageActivity(mActivity);
    }

    //消息
    @Override
    public void onNews() {
//       IntentManager.toNewsPageActivity(mActivity);
    }

    //个人信息
    @Override
    public void onPersonalInformation() {
        IntentManager.toPersonalInformationActivity(mActivity);
    }

    //行为分
    @Override
    public void onIntegral() {
        IntentManager.toIntegralPageActivity(mActivity);
    }

    //拒单率
    @Override
    public void onBalance() {
        ToastUtils.showShort("拒单率");
    }

    //准点率
    @Override
    public void onPunctualityRate() {
        ToastUtils.showShort("准点率");
    }

    //躺赚
    @Override
    public void onLieEarn() {
        IntentManager.toLieEarnActivity(mActivity, loginInfoData.avatar, loginInfoData.nickname);
    }

    //会员中心
    @Override
    public void onMemberCenter() {
//        ToastUtils.showShort("会员中心");
//        VoiceManager.getInstance().voicePlayback("您有新的订单来了");
    }

    //我的钱包
    @Override
    public void onMyWallet() {
        IntentManager.toMyWalletActivity(mActivity);
    }

    //收入统计
    @Override
    public void onCommonAddress() {
        ToastUtils.showShort("收入统计");
    }

    //单子热力图
    @Override
    public void onCollectionDriver() {
        ToastUtils.showShort("单子热力图");
    }

    //接单检测
    @Override
    public void onInvoice() {
        ToastUtils.showShort("接单检测");
    }

    //我的好评
    @Override
    public void onScan() {
        ToastUtils.showShort("我的好评");
    }

    //优惠加油
    @Override
    public void onCustomerService() {
        ToastUtils.showShort("优惠加油");
    }

    //我的豪车
    @Override
    public void onFeedback() {
        ToastUtils.showShort("我的豪车");
    }

    //机佬大学
    @Override
    public void onEnterpriseServices() {
        ToastUtils.showShort("机佬大学");
    }

    //违章与诉讼
    @Override
    public void onOiling() {
        ToastUtils.showShort("违章与诉讼");
    }

    //客服中心
    @Override
    public void onSecKill() {
        ToastUtils.showShort("客服中心");
    }

    //分公司查询
    @Override
    public void onBranchOffice() {
        ToastUtils.showShort("分公司查询");
    }

    //规则中心
    @Override
    public void onRuleCenter() {
        ToastUtils.showShort("规则中心");
    }

    //邀请有奖
    @Override
    public void onInvitePrize() {
        IntentManager.toInvitePrizeActivity(mActivity);
    }

    //拉新客赚钱
    @Override
    public void onMakeMoney() {
        ToastUtils.showShort("拉新客赚钱");
    }

    //机械车贴
    @Override
    public void onCarSticker() {
        ToastUtils.showShort("机械车贴");
    }

    //金钢佬商城
    @Override
    public void onShoppingMall() {
        ToastUtils.showShort("金钢佬商城");
    }

    //租购机械
    @Override
    public void onRentBuy() {
        ToastUtils.showShort("租购机械");
    }

    @Override
    public void returnMineData(LoginInfoBean data) {
        loginInfoData =data;
        mBinding.setData(data);
    }

    @Override
    protected boolean isRegisterEvent() {
        return true;
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onModifyInformationEvent(ModifyInformationEvent event) {
        requestNetData();
    }
}
